/*
 * AnimationNode.cpp
 *
 *  Created on: 2011/08/07
 *      Author: naoki
 */

#include "StdAfx.h"
#include "NTEngine/NTEngine.h"
#include "NTEngine/Base/RefString.h"
#include "Scene/src/AnimationNode.h"
#include "Scene/src/ContainerImpl.h"
#include "Scene/src/Curve.h"

#include "NTEngine/Xml/Element.h"
#include "NTEngine/Xml/Attribute.h"

namespace NTEngine {
namespace Scene {

AnimationNode::AnimationNode( Xml::ConstElement& e, Container::Impl& c ){
	ASSERT( RefString( "Node" ) == e.name() ); //Nodeだよね？
	ASSERT( e.childNumber() > 0 ); //カーブ一個はあるよね？
	//名前取得
	int an = e.attributeNumber();
	for ( int i = 0; i < an; ++i ){
		ConstAttribute a = e.attribute( i );
		if ( RefString( "name" ) == a.name() ){
			mName = c.allocateString( RefString( a.value() ) );
		}
	}
	mCurveNumber = e.childNumber();
	mCurves = static_cast< Curve* >( OPERATOR_NEW( sizeof( Curve ) * mCurveNumber ) );
	for ( int i = 0; i < mCurveNumber; ++i ){
		ConstElement child = e.child( i );
		new ( &mCurves[ i ] ) Curve( child );
	}
}

} //namespace Scene
} //namespace NTEngine
